export function useDefer() {
  const frameCount = ref(0)
  let rafId: number
  function updateFrameCount(maxCount = 100) {
    rafId = requestAnimationFrame(() => {
      frameCount.value++
      if (frameCount.value >= maxCount) return
      updateFrameCount()
    })
  }
  updateFrameCount()
  onUnmounted(() => {
    cancelAnimationFrame(rafId)
  })
  return function defer(n: number) {
    return frameCount.value >= n
  }
}
